/**
 * Copyright © 2020 易久批信息技术有限公司. All rights reserved.
 */
package com.dysm.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author xiay
 * @since 2020/12/12 10:23 下午
 */
public class ChessFlyweightFactory {

    private static Map<String, ChessFlyweight> map = new HashMap<>();

    public static ChessFlyweight get(String color) {
        ChessFlyweight chessFlyweight = map.get(color);
        if (chessFlyweight != null) {
            return chessFlyweight;
        } else {
            chessFlyweight = new ChessFlyweight(color);
            map.put(color, chessFlyweight);
            return chessFlyweight;
        }
    }
}
